# def fac(k):
#     i = 2
#     t = 1
#     while i <= k:
#         t *= i
#         i += 1
#     return t
# def sum(n):
#     s = 0
#     i = 1
#     while i <= n:
#         s = s + fac(i)
#         i += 1
#     return s
# print('1!+4!+7!...10!=',sum(50))
def fun1(n):
    res = 1
    i = 1
    while i <= n:
        res *= i
        i += 1
    return res

def fun2(k):
    res01 = 0
    i = 1
    while i <= k:
        res01 += fun1(i)
        i += 3
    return res01

if __name__ == '__main__':
    result = fun2(50)
    print(result)
